<template>
	<view class="app_Cont">
		<view class="showCont" v-if="showCont">
			<view class="navCont">
				<view class="navItem" @click="navFn(item)" :key="index" v-for="(item,index) in navArr">
					<view :class="navId==item.id?'navText navActive':'navText'">{{item.name}}</view>
					<image v-if="navId==item.id" class="navImg" src="/static/img/navImg.png"></image>
				</view>
			</view>
			<scroll-view class="workCont" scroll-y="true" @scrolltolower="scrolltolower" lower-threshold="10" >
				<view class="workItem" @click="detailFn(item)" :key="index" v-for="(item,index) in listArr">
					<view class="workHead">
						<view class="workName">{{item.sign_number}}</view>
						<view class="workMoney">
							<text class="redText" v-if="item.pay_status==1">待付款</text>
							<text class="orgText" v-if="item.pay_status==2">待接单</text>
							<text class="blueText" v-if="item.pay_status==3">办理中</text>
							<text  class="greenText"  v-if="item.pay_status==4">已完成</text>
							<text  class="blackText" v-if="item.pay_status==5">已取消</text>
						</view>
					</view>
					<view class="workInfo">
						<view class="infoItem">
							<view class="infoName">证件名称</view>
							<view class="infoText">{{item.accreditation_name}}</view>
						</view>
						<view class="infoItem">
							<view class="infoName">支付时间</view>
							<view class="infoText">{{item.pay_time}}</view>
						</view>
					</view>
					<view class="infoUnder">
						<view class="moneyText">¥{{item.accreditation_money}}</view>
						<view class="underCtrl">
							<view class="ctrlBtn plainBtn" v-if="item.pay_status==1||item.pay_status==2">取消订单</view>
							<view class="ctrlBtn" v-if="item.pay_status==1">立即支付</view>
						</view>
					</view>
				</view>
				<noData v-if="listArr.length==0&&!isChange"></noData>
				<loadMore v-if="!isChange&&last_page==page"></loadMore>
			</scroll-view>
		</view>
		<load v-if="!showCont||isChange"></load>
	</view>
</template>

<script>
	import api from '@/http/api.js'
	import load from '@/components/load.vue'
	import noData from '@/components/noData.vue'
	import loadMore from '@/components/loadMore.vue'
	export default {
		components:{load,noData,loadMore},
		data() {
			return {
				showCont:false,
				navArr:[
					{name:'全部订单',id:0},
					{name:'待付款',id:1},
					{name:'待接单',id:2},
					{name:'已完成',id:4},
				],
				navId:0,
				page:1,
				per_page:10,
				last_page:0,
				listArr:[],
				isChange:false,
			};
		},
		methods:{
			scrolltolower(){
				if(this.page<this.last_page){
					this.page++
					this.isChange = true
					this.getData()
				}
			},
			detailFn(item){
				uni.navigateTo({
					url: 'obtainRecordDetail/obtainRecordDetail?id='+item.user_accreditation_sign_id
				});
			},
			navFn(item){
				this.navId = item.id
				this.serchFn()
			},
			serchFn(){
				this.page =1
				this.listArr = []
				this.isChange = true
				this.getData()
			},
			getData(){
				let data = {
					pay_status:this.navId,
					page:this.page,
					per_page:this.per_page,
				}
				api.getRequst(data,'/api/My/accreditationRecord').then((res)=>{
					if(res.code==1){
						let arr = res.data.data
						for(let item of arr){
							this.listArr.push(item)
						}
						this.last_page = res.data.last_page
					}
					this.showCont = true
					this.isChange = false
				})
			}
		},
		onLoad() {
			this.getData()
		}
	}
</script>

<style lang="scss">
.showCont{
	height: 100vh;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}
.navCont{
	width: 100%;
	padding: 80rpx 4% 30rpx;
	box-sizing: border-box;
	display: flex;
	justify-content: space-between;
	.navItem{
		width: 22%;
		text-align: center;
		position: relative;
		.navImg{
			position: absolute;
			height: 80rpx;
			width: 80rpx;
			left: 20rpx;
			top: -66rpx;
			transform: rotateY(180deg);
			z-index: 1;
		}
		.navText{
			width: 100%;
			border-radius: 50rpx;
			background-color: #fff;
			padding: 15rpx 0;
			position: relative;
			z-index: 2;
			color: #666;
			font-size: 26rpx;
		}
		.navActive{
			background-color: #3f55cc;
			color: #fff;
		}
	}
}

.workCont{
		width: 100%;
		height: 500rpx;
		flex: 1;
		padding: 20rpx 4% 30rpx;
		overflow-y: auto;
		box-sizing: border-box;
		.workItem{
			background-color: #fff;
			padding: 30rpx 4% 20rpx;
			margin-bottom: 20rpx;
			border-radius: 10rpx;
			box-sizing: border-box;
			.workHead{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.workName{
					width: 100rpx;
					font-size: 28rpx;
					font-weight: bold;
					flex: 1;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					margin-right: 30rpx;
				}
				.workMoney{
					font-size: 24rpx;
					
				}
			}
			.workInfo{
				.infoItem{
					display: flex;
					align-items: center;
					margin-top: 15rpx;
					.infoName{
						width: 120rpx;
						margin-right: 15rpx;
						color: #666;
					}
					.infoText{
						flex: 1;
						width: 100rpx;
						.redText{
							color: #ff5757;
						}
					}
					
				}
			}
			.infoUnder{
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				padding-top: 20rpx;
				.moneyText{
					color: #ff5757;
					font-size: 28rpx;
				}
				.underCtrl{
					display: flex;
					align-items: center;
					.ctrlBtn{
						background-color: #3f55cc;
						border: 1px solid #3f55cc;
						box-sizing: border-box;
						color: #fff;
						font-size: 24rpx;
						padding: 12rpx 28rpx;
						border-radius: 10rpx;
						margin-left: 30rpx;
						box-sizing: border-box;
					}
					.plainBtn{
						background-color: #fff;
						color: #3f55cc;
					}
				}
			}
		}
	}
</style>
